import java.util.Arrays;
import java.util.Random;

public class Test {

    //逆序初始化
    public static void initOrder(int[] arr){
        int sz = arr.length;
        for (int i = 0; i < sz; i++) {
            arr[i] = sz-i;
        }
    }

    //无序
    public static void notOrder(int[] arr){
        int sz = arr.length;
        Random random = new Random();
        for (int i = 0; i < sz; i++) {
            arr[i] = random.nextInt(100)+1;
        }
    }

    public static void testInsertionSort(int[] arr){
        int[] tmp = Arrays.copyOf(arr,arr.length);
        long begin = System.currentTimeMillis();
        Sort.InsertionSort(tmp);
        long end = System.currentTimeMillis();
        System.out.println("直接插入排序：" + (end - begin));
    }

    public static void testShellSort(int[] arr){
        int[] tmp = Arrays.copyOf(arr,arr.length);
        long begin = System.currentTimeMillis();
        Sort.ShellSort(tmp);
        long end = System.currentTimeMillis();
        System.out.println("希尔插入排序：" + (end - begin));
    }

    public static void main(String[] args) {
        int[] arr = new int[15];
        for (int i = 0; i < 10; i++) {
            notOrder(arr);
            System.out.println(Arrays.toString(arr));
            Sort.countSort(arr);
            System.out.println(Arrays.toString(arr));
            System.out.println();
        }
        /*int[] arr = {32, 16, 27, 44, 44, 64, 22, 1};
        Sort.mergeSortNor(arr);
        System.out.println(Arrays.toString(arr));*/
    }
}
